// MainDlg.h : interface of the CMainDlg class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once
#include "resource.h"
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
#include <Windows.h>
#include <atlctrls.h>
#include "ComFunRestry.h"

class CMainDlg : public CDialogImpl<CMainDlg>
{
public:
	enum { IDD = IDD_MAINDLG };

	BEGIN_MSG_MAP(CMainDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
		COMMAND_HANDLER(IDC_BUTTON_BACK, BN_CLICKED, OnBnClickedButtonStored)
		COMMAND_HANDLER(IDC_BUTTON_ADDNEW, BN_CLICKED, OnBnClickedButtonAddNew)
		COMMAND_HANDLER(IDC_BUTTON_UP, BN_CLICKED, OnBnClickedButtonUp)
		COMMAND_HANDLER(IDC_BUTTON_DOWN, BN_CLICKED, OnBnClickedButtonDown)
		COMMAND_HANDLER(IDC_BUTTON_SAVE, BN_CLICKED, OnBnClickedButtonSave)
	END_MSG_MAP()

	//BEGIN_DDX_MAP(CMainDlg)
	//	DDX_CONTROL(IDC_EDIT, m_wndEdit)
	//END_DDX_MAP()

// Handler prototypes (uncomment arguments if needed):
//	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
//	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
//	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);

	LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

	struct CmpByKeyLength
	{
		bool operator()(const CString& k1, const CString& k2)
		{
			return 1;
		}
	};
protected:
	void InitList();
	void LoadCurrentUesdProject(std::map<CString, CString>& mapCurrentUserProject);
	void FillCurrentUsedProjectList();
	void RefreshCurrentList(BOOL bRefreshFileName, BOOL bSort = TRUE);
	void RefreshStoredList();
	void LoadStoredProject();
	void FillStoredProjectList();

	void GetStoredConfigpath(CString& strPath);

	//static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);

public:
	// //Left tree
	//CListCtrl m_lstCurretnUsed;
	CListViewCtrl m_lstCurretnUsed;
	CListViewCtrl m_lstStored;
//	LRESULT OnNMThemeChangedListCurrent(int /*idCtrl*/, LPNMHDR pNMHDR, BOOL& /*bHandled*/);
	LRESULT OnBnClickedButtonStored(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedButtonAddNew(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedButtonUp(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedButtonDown(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedButtonSave(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
};
